/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package verins.beans;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author miguel
 */
@Entity
@Table(name = "permisoxrol", schema = "verinscribe")
@NamedQueries({
    @NamedQuery(name = "Permisoxrol.findAll", query = "SELECT p FROM Permisoxrol p"),
    @NamedQuery(name = "Permisoxrol.findByIdrol", query = "SELECT p FROM Permisoxrol p WHERE p.permisoxrolPK.idrol = :idrol"),
    @NamedQuery(name = "Permisoxrol.findByIdpermiso", query = "SELECT p FROM Permisoxrol p WHERE p.permisoxrolPK.idpermiso = :idpermiso"),
    @NamedQuery(name = "Permisoxrol.findByEstado", query = "SELECT p FROM Permisoxrol p WHERE p.estado = :estado")})
public class Permisoxrol implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PermisoxrolPK permisoxrolPK;
    @Column(name = "estado")
    private Character estado;
    @JoinColumn(name = "idrol", referencedColumnName = "idrol", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Rol rol;
    @JoinColumn(name = "idpermiso", referencedColumnName = "idpermiso", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Permiso permiso;

    public Permisoxrol() {
    }

    public Permisoxrol(PermisoxrolPK permisoxrolPK) {
        this.permisoxrolPK = permisoxrolPK;
    }

    public Permisoxrol(int idrol, int idpermiso) {
        this.permisoxrolPK = new PermisoxrolPK(idrol, idpermiso);
    }

    public PermisoxrolPK getPermisoxrolPK() {
        return permisoxrolPK;
    }

    public void setPermisoxrolPK(PermisoxrolPK permisoxrolPK) {
        this.permisoxrolPK = permisoxrolPK;
    }

    public Character getEstado() {
        return estado;
    }

    public void setEstado(Character estado) {
        this.estado = estado;
    }

    public Rol getRol() {
        return rol;
    }

    public void setRol(Rol rol) {
        this.rol = rol;
    }

    public Permiso getPermiso() {
        return permiso;
    }

    public void setPermiso(Permiso permiso) {
        this.permiso = permiso;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (permisoxrolPK != null ? permisoxrolPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Permisoxrol)) {
            return false;
        }
        Permisoxrol other = (Permisoxrol) object;
        if ((this.permisoxrolPK == null && other.permisoxrolPK != null) || (this.permisoxrolPK != null && !this.permisoxrolPK.equals(other.permisoxrolPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "verins.beans.Permisoxrol[permisoxrolPK=" + permisoxrolPK + "]";
    }

}
